import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:get/get.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:sp_util/sp_util.dart';
import 'package:yp/services/api.dart';
import 'jfsubsidiary_logic.dart';

class JfsubsidiaryPage extends StatefulWidget {
  @override
  _JfsubsidiaryPageState createState() => _JfsubsidiaryPageState();
}

class _JfsubsidiaryPageState extends State<JfsubsidiaryPage> {
  List page_model=[];

  getitem() {
    var params = {"data_sign": 0, "channel_num_id": 98, "use_platform": 3, "access_token": SpUtil.getString('token'), "create_dtme_end": "", "create_dtme_start": "", "curpage": "", "pagecount": "", "integral_type": ""};
    Api.getMemberPointsTurnover(params).listen((event) {
      if (event['code'] == 0) {
        if (event['page_model'] != null && event['page_model']['data'] != null) {
          setState(() {
                page_model = event['page_model']['data'];
          });

        }
      }
    });
  }

  @override
  void initState() {
    super.initState();
    getitem();
  }

  @override
  Widget build(BuildContext context) {
    final logic = Get.put(JfsubsidiaryLogic());
    final state = Get.find<JfsubsidiaryLogic>().state;
    return Scaffold(
      appBar: AppBar(
        title: Text('积分详情'),
        backgroundColor: Colors.deepOrange,
      ),
      body: Container(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Container(
                color: Colors.white,
                width: 750.w,
                height: 100.w,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Row(
                      children: [
                        SizedBox(
                          width: 20.w,
                        ),
                        Text(
                          '总积分:',
                          style: TextStyle(fontSize: 26.sp),
                        ),
                        SizedBox(
                          width: 10.w,
                        ),
                        Text(
                          '${Get.arguments['userIntegralNum']}',
                          style: TextStyle(fontSize: 36.sp, color: Colors.deepOrange),
                        ),
                      ],
                    ),

                  ],

                )),
            Container(
              height: 20.w,
              width: double.infinity,
              color: Colors.grey[200],
            ),
            jfList()

          ],
        ),
      ),
    );
  }

  Widget jfList() {
    return Container(
      child: Column(
        children: page_model.map((e) {
          return item(e);
        }).toList(),
      ),
    );
  }

  Widget item(e) {
    return Container(
      height: 130.w,
      decoration: BoxDecoration(border: Border(bottom: BorderSide(width: 1, color: Color(0xffe5e5e5)))),
      child: Padding(
        padding: EdgeInsets.all(20.w),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  e['memo'].toString(),
                  style: TextStyle(fontSize: 32.sp),
                ),
                SizedBox(
                  height: 10.w,
                ),
                Text(e['create_dtme'].toString(), style: TextStyle(fontSize: 25.sp))
              ],
            ),
            Text(
              e['reserved_integral'].toString(),
              style: TextStyle(fontSize: 32.sp, color: Colors.red),
            )
          ],
        ),
      ),
    );
  }
}
